package org.hackystat.projectbrowser.page.settrigger;

import java.io.Serializable;
import java.util.ArrayList;
import org.hackystat.ambientdevice.server.jaxb.Trigger;

/**
 * The Model of all triggers.
 * 
 * @author Edward Kim
 * 
 */
public class TriggerModel implements Serializable {

  /** Support serialization. */
  private static final long serialVersionUID = 1L;

  Trigger trigger;
  String type;
  String sdt;
  String id;
  String value;
  String minValue;
  String maxValue;
  String property;

  /**
   * Constructor for the trigger model.
   * 
   * @param trigger The trigger for the model.
   */
  public TriggerModel(org.hackystat.ambientdevice.server.jaxb.Trigger trigger) {
    this.trigger = trigger;
  }

  /**
   * Gets the choices for editing.
   * 
   * @param type The type of trigger.
   * @return An list of choices.
   */
  protected static ArrayList<String> getChoices(String type) {
    ArrayList<String> list = new ArrayList<String>();
    if ("type".equals(type)) {
      list.add("SensorData");
      list.add("Coverage");
    }
    else if ("sdt".equals(type)) {
      list.add("UnitTest");
      list.add("Commit");
      list.add("Build");
    }
    else if ("property".equals(type)) {
      list.add("Result");
      list.add("Target");
      list.add("tool");
    }
    else if ("value".equals(type)) {
      list.add("Fail");
      list.add("Success");
      list.add("pass");
    }
    else if ("SensorData".equals(type)) {
      System.out.println("IN SENSOR DATA");
      list.add("UnitTest");
      // list.add("Commit");
      list.add("Build");
    }
    else if ("Build".equals(type) || "UnitTest".equals(type)) {
      list.add("Result");
      list.add("Tool");
      list.add("Target");
    }
    else if ("Result".equals(type)) {
      list.add("Success");
      list.add("Failure");
    }
    else if ("Target".equals(type)) {
      list.add("Compile");
      list.add("junit.sensor");
      list.add("pmd.sensor");
      list.add("checkstyle.sensor");
    }
    else if ("Tool".equals(type)) {
      list.add("Ant");
      list.add("Eclipse");
    }
    else if ("Coverage".equals(type)) {
      list.add("Not Applicable");
    }
    else if ("Not Applicable".equals(type)) {
      list.add("Compare");
    }
    else if ("Compare".equals(type)) {
      list.add("50%");
      list.add("75%");
      list.add("90%");
    }
    else {
      list.add("NOTHING");
    }

    return list;
  }

  /**
   * Sets the type.
   * 
   * @param type The type to set.
   */
  public void setType(String type) {
    this.type = type;
  }

  /**
   * Gets the type.
   * 
   * @return The type.
   */
  public String getType() {
    return this.type;
  }

  /**
   * Sets the SDT.
   * 
   * @param type The SDT to set.
   */
  public void setSdt(String type) {
    this.sdt = type;
  }

  /**
   * Gets the SDT.
   * 
   * @return The SDT.
   */
  public String getSdt() {
    return this.sdt;
  }

  /**
   * Sets the property.
   * 
   * @param type The property to set.
   */
  public void setProperty(String type) {
    this.property = type;
  }

  /**
   * Gets the property.
   * 
   * @return The property.
   */
  public String getProperty() {
    return this.property;
  }

  /**
   * Sets the value.
   * 
   * @param type The value to set.
   */
  public void setValue(String type) {
    this.value = type;
  }

  /**
   * Gets the value.
   * 
   * @return The value.
   */
  public String getValue() {
    return this.value;
  }

  /**
   * The getter for the trigger.
   * 
   * @return The trigger.
   */
  public Trigger getTrigger() {
    return this.trigger;
  }

  /**
   * The setter for the trigger.
   * 
   * @param trigger The trigger to set.
   */
  public void setTrigger(Trigger trigger) {
    this.trigger = trigger;
  }

  /**
   * The setter for the trigger type.
   * 
   * @param string The trigger type.
   */
  public void setTriggerType(String string) {
    this.trigger.setType(string);
  }

  /**
   * The getter for the trigger type.
   * 
   * @return The trigger type.
   */
  public String getTriggerType() {
    return this.trigger.getType();
  }

  /**
   * The setter for the trigger SDT.
   * 
   * @param string The trigger SDT to set.
   */
  public void setTriggerSDT(String string) {
    this.trigger.setSDT(string);
  }

  /**
   * The getter for the trigger SDT.
   * 
   * @return The trigger SDT.
   */
  public String getTriggerSDT() {
    return this.trigger.getSDT();
  }

  /**
   * The setter for the trigger property.
   * 
   * @param string The trigger property to set.
   */
  public void setTriggerProperty(String string) {
    this.trigger.setProperty(string);
  }

  /**
   * The getter for the trigger property.
   * 
   * @return The trigger property.
   */
  public String getTriggerProperty() {
    return this.trigger.getProperty();
  }

  /**
   * The setter for th trigger value.
   * 
   * @param string The trigger value to set.
   */
  public void setTriggerValue(String string) {
    this.trigger.setValue(string);
  }

  /**
   * The getter for the trigger value.
   * 
   * @return The trigger value.
   */
  public String getTriggerValue() {
    return this.trigger.getValue();
  }

  /**
   * The setter for the trigger min value.
   * 
   * @param num The min value to set.
   */
  public void setTriggerMinValue(Double num) {
    this.trigger.setMinValue(num);
  }

  /**
   * The getter for the trigger min value.
   * 
   * @return The trigger min value.
   */
  public String getTriggerMinValue() {
    return this.trigger.getMinValue().toString();
  }

  /**
   * The setter for the trigger max value.
   * 
   * @param num The trigger max value to set.
   */
  public void setTriggerMaxValue(Double num) {
    this.trigger.setMaxValue(num);
  }

  /**
   * The getter for the trigger max value
   * 
   * @return The trigger max value.
   */
  public String getTriggerMaxValue() {
    return this.trigger.getMaxValue().toString();
  }

}
